package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username 用户名
     * @return Employee 员工对象
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 根据id查询员工
     *
     * @param empId 员工id
     * @return Employee 员工对象
     */
    @Select("select * from employee where id = #{empId}")
    Employee getById(Long empId);

    /**
     * 分页查询员工
     *
     * @param employeePageQueryDTO 分页查询参数
     * @return List<Employee> 员工列表
     */
    List<Employee> page(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 新增员工
     *
     * @param employee 员工信息
     */
    @AutoFill(OperationType.INSERT)
    void save(Employee employee);

    /**
     * 更新员工
     *
     * @param employee 员工信息
     */
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);
}
